package com.library.service.impl;

import com.library.bean.User;
import com.library.mapper.UserMapper;
import com.library.service.UserService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

@Service
public class UserServiceImpl implements UserService {
   @Resource
   private UserMapper userMapper;

    @Override
    public Map<String, Object> userLogin(User user) {
        User loginUser = userMapper.selectUserByUserNameAndPassword(user);
        Map<String,Object> map = new HashMap();
        if(loginUser!=null){
            map.put("loginUser",loginUser);
            return map;
        }
        if(userMapper.selectUserByUserName(user.getUsername())!=null){
            map.put("msg","密码错误");
            return map;
        }

        map.put("msg","用户名不存在");
        return map;
    }
}
